import React, {Component} from 'react'
import {Animated} from 'react-native'

class FadeInView extends Component {
    constructor(props) {
        super(props)
    }
    state = {
        fadeAnim: new Animated.Value(0),
        duration: 300,
    }
    animation() {
        const {fadeAnim, duration} = this.state
        return Animated
            .timing(fadeAnim, {
            toValue: 1,
            duration: duration,
            //  useNativeDriver: true
        })
    }
    componentDidMount() {
     this.animation().start()
    }
    render() {
        return (
            <Animated.View
                style={{
                ...this.props.style,
                opacity: this.state.fadeAnim
            }}>
                {this.props.children}
            </Animated.View>
        )
    }
}
export default FadeInView